package com.streetsmart;

import java.text.ParseException;
import java.util.ArrayList;

import org.json.JSONException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
/**
 * Test class with a simple text view that displays the schedule. 
 *
 */
public class testScheduleDisplay extends Activity {
	
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.testdbrow);
		TextView textview = (TextView) findViewById(R.id.listItem);
		testcase one = new testcase(getApplicationContext());
		ArrayList<ScheduleListItem> schedule = new ArrayList<ScheduleListItem>();
		try {
			schedule = one.runTestCase();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		textview.setText("");
		for(int i = 0; i < schedule.size(); i++){
			ScheduleListItem item = schedule.get(i);
			textview.append(item.getEvent().getName() + "\t" + item.getEvent().getLocation().getAddress() + "\t" + item.getStartTime().toLocaleString());
			textview.append("\n");
		}
	}
}
